package cn.yuan.xiaoyu.calendarmodule.activity;

import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;
import cn.yuan.xiaoyu.R;
import cn.yuan.xiaoyu.calendarmodule.bean.WeekViewEvent;
import cn.yuan.xiaoyu.calendarmodule.view.MonthLoader;
import cn.yuan.xiaoyu.calendarmodule.view.WeekView;
import cn.yuan.xiaoyu.commonmodule.activity.BaseActivity;
import cn.yuan.xiaoyu.commonmodule.utils.StatusBarCompatUtils;

/**
 * Created by yukuoyuan on 2017/3/1.
 * 这是一个日历的界面
 */

public class CalendarActivity extends BaseActivity implements WeekView.EventClickListener, WeekView.EventLongPressListener {
    @Bind(R.id.iv_toolbar_left)
    ImageView ivToolbarLeft;
    @Bind(R.id.tv_toolbar_title)
    TextView tvToolbarTitle;
    @Bind(R.id.weekView)
    WeekView weekView;

    @Override
    protected void bindPresenter() {

    }

    @Override
    protected void initData(Bundle extras) {
        weekView.setOnEventClickListener(this);
        weekView.setMonthChangeListener(mMonthChangeListener);
        weekView.setEventLongPressListener(this);
    }

    MonthLoader.MonthChangeListener mMonthChangeListener = new MonthLoader.MonthChangeListener() {
        @Override
        public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {
            // Populate the week view with some events.
            List<WeekViewEvent> events = new ArrayList<>();
            return events;
        }
    };

    @Override
    public int getContentLayout() {
        return R.layout.activity_calendar;
    }

    @Override
    protected void initToolbar() {
        StatusBarCompatUtils.compat(this);
        ivToolbarLeft.setVisibility(View.VISIBLE);
        tvToolbarTitle.setVisibility(View.VISIBLE);
        tvToolbarTitle.setText("日历控件");
    }

    @OnClick({R.id.iv_toolbar_left, R.id.tv_toolbar_right})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_toolbar_left:
                onBackPressed();
                break;
            case R.id.tv_toolbar_right:
                break;
        }
    }

    @Override
    public void onEventClick(WeekViewEvent event, RectF eventRect) {

    }

    @Override
    public void onEventLongPress(WeekViewEvent event, RectF eventRect) {

    }
}
